//
//  BaseViewController.m
//  LiquorChain
//
//  Created by apple on 2018/12/24.
//  Copyright © 2018年 王冬. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()
@end

@implementation BaseViewController

- (void)viewDidLoad {
   [super viewDidLoad];
       self.view.backgroundColor = [UIColor whiteColor];

       

}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
     [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor],NSFontAttributeName : [UIFont systemFontOfSize:17]}];
     
     
//     CGRect frame = CGRectMake(0, 0, kSCREEN_WIDTH, StateHeight+44);
//     UIImageView *imgview = [[UIImageView alloc]initWithFrame:frame];
//     UIGraphicsBeginImageContext(imgview.frame.size);
//     CGContextRef context = UIGraphicsGetCurrentContext();
//     CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
//     CGContextScaleCTM(context, frame.size.width, frame.size.height);
//     CGFloat colors[] = {
//
//         255.0/255.0, 97.0/255.0, 0/255.0, 1.0,
//
//         255.0/255.0, 80.0/255.0, 2.0/255.0, 1.0,
//
//     };
//     CGGradientRef backGradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4));
//     CGColorSpaceRelease(rgb);
//     //设置颜色渐变的方向，范围在(0,0)与(1.0,1.0)之间，如(0,0)(1.0,0)代表水平方向渐变,(0,0)(0,1.0)代表竖直方向渐变
//     CGContextDrawLinearGradient(context, backGradient, CGPointMake(0, 0), CGPointMake(1.0, 0), kCGGradientDrawsBeforeStartLocation);
//
//     [self.navigationController.navigationBar setBackgroundImage:UIGraphicsGetImageFromCurrentImageContext()  forBarMetrics:UIBarMetricsDefault];
     
     
      [self.navigationController.navigationBar setBackgroundImage:[UIColor imageWithColor:[UIColor whiteColor]] forBarMetrics:UIBarMetricsDefault];
     [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
     [self setupLeftBarButton];
  
}

#pragma mark - 自定义返回按钮
- (void)setupLeftBarButton {
    
    
    NSArray *arrViewControllers = self.navigationController.viewControllers;
    
    if ([arrViewControllers indexOfObject:self] > 0)
        
    {
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                             initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
                                             style:UIBarButtonItemStyleDone
                                             target:self
                                             action:@selector(leftBarButtonClick)];
        
    }
    // 防止返回手势失效
    self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
}

#pragma mark - 返回按钮的点击事件
- (void)leftBarButtonClick {
    [self.navigationController popViewControllerAnimated:YES];
}






@end
